import pyAxios from "./http";

// 获取该学生的班级信息
async function getStudentClass(studentId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/student/getStudentClass',
            params:{
                studentId
            }
        })
        return response;
    } catch (error) {
        console.log(error);

    }
}

// 获取该学生的班级信息
async function joinClass(studentId,classCode) {
    try {
        const response = await pyAxios({
            method: 'post',
            url: '/student/joinClass',
            data:{
                studentId,
                classCode
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

// 获取资料文件下载
async function getStudentMaterial(studentId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/student/getStudentMaterial',
            params:{
                studentId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

// 退出班级
async function quitClass(studentId,classId) {
    try {
        const response = await pyAxios({
            method: 'delete',
            url: '/student/quitClass',
            params:{
                studentId,
                classId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}


// 获取考试信息
async function getStudentExam(studentId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/student/getStudentExam',
            params:{
                studentId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

// 进入考试获取考试信息
async function starTest(answerSheetId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/student/starTest',
            params:{
                answerSheetId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

//中途提交试卷
async function midwaySubmit(fromData) {
    try {
        const response = await pyAxios({
            method: 'post',
            url: '/student/midwaySubmit',
            data:fromData
            
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

//中途提交试卷
// 获取该学生的班级信息
async function submitExam(fromData) {
    try {
        const response = await pyAxios({
            method: 'post',
            url: '/student/submitExam',
            data:fromData
            
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}
// 进入考试获取考试信息
async function getAlreadySubmitExam(studentId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/student/getAlreadySubmitExam',
            params:{
                studentId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

// 进入考试成绩详情
async function getGradeDetails(answerSheetId) {
    try {
        const response = await pyAxios({
            method: 'get',
            url: '/student/getGradeDetails',
            params:{
                answerSheetId
            }
        })
        return response;
    } catch (error) {
        console.log(error);
    }
}

export default {getGradeDetails,getAlreadySubmitExam,submitExam,midwaySubmit,starTest,getStudentExam,getStudentClass,joinClass,getStudentMaterial,quitClass}